package com.ruoyi.web.controller.course;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.course.domain.SysStudentMistake;
import com.ruoyi.course.domain.SysStudentNote;
import com.ruoyi.course.service.ISysStudentNoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 学员内容Controller
 * 
 * @author YJF
 */
@RestController
@RequestMapping("/student/grade")
public class SysStudentNoteController extends BaseController
{
    @Autowired
    private ISysStudentNoteService sysStudentNoteService;

    /**
     * 查询成绩列表
     */
    @PreAuthorize("@ss.hasPermi('student:gradeList')")
    @GetMapping("/gradeList")
    public TableDataInfo gradeList(SysStudentNote sysStudentNote)
    {
        startPage();
        List<SysStudentNote> list = sysStudentNoteService.selectSysStudentNoteList(sysStudentNote);
        return getDataTable(list);
    }

    /**
     * 学员错题记录
     * 只能看到自己的
     */
    @PreAuthorize("@ss.hasPermi('student:mistake:list')")
    @GetMapping("/mistake")
    public TableDataInfo mistake(SysStudentMistake sysStudentMistake)
    {
        startPage();
        List<SysStudentMistake> list = sysStudentNoteService.selectMistakeList(sysStudentMistake);
        return getDataTable(list);
    }


    /**
     * 导出学员成绩列表
     */
    @PreAuthorize("@ss.hasPermi('student:grade:export')")
    @Log(title = "学员成绩", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysStudentNote sysStudentNote)
    {
        List<SysStudentNote> list = sysStudentNoteService.selectSysStudentNoteList(sysStudentNote);
        ExcelUtil<SysStudentNote> util = new ExcelUtil<SysStudentNote>(SysStudentNote.class);
        util.exportExcel(response, list, "学员成绩数据");
    }

}
